import React, {Component} from 'react';
import {
  View,
  Text,
  TouchableOpacity,
} from 'react-native';

import Config from '../../config';
import Colors from '../../common/Colors';
import CommonStyles from '../../common/CommonStyles';
import SizeUtils from '../../common/SizeUtils';
import ZHP_Constants from './ZHP_Constants';
import CommonListPage from '../common/CommonListPage';
import ZHP_PostItemView from './ZHP_PostItemView';
import ZHP_RequestPostsAction from '../../actions/zahuopu/ZHP_RequestPostsAction';

export default class ZHP_ListPage extends CommonListPage {
  constructor(props) {
    super(props);

    this._dataKey = "post_id";
  }

  _onRenderItem(data, index) {
    return (<ZHP_PostItemView data={data} index={index} showNum = {true} />)
  }

  _getListViewStyle() {
    return {
        width:SizeUtils.getWindowSize().width,
        height:(SizeUtils.getWindowSize().height - Config.paddingTop - SizeUtils.translateDesignHeightToCode(20)),
        backgroundColor:"#ffffff00"};
  }

  _requestData(page, listView) {
    //排序方式，1最新，2最热, 3精选（72小时内的帖子点赞）
    new ZHP_RequestPostsAction().call(listView, {sort_id:this.props.pageData.routeData.sort_id,
      tag:1, page:page, page_size:10});
  }

  _getTitle() {
    if(this.props.pageData.routeData.sort_id === 1) {
      return "最新问题";
    }
    else if(this.props.pageData.routeData.sort_id === 2) {
      return "回答热榜";
    }
  }
}
